Skip to content

Conversation

KurtE
Copy link

@KurtE KurtE commented Aug 14, 2025

We need to start the clock in the same way as we do for the Arduino GIGA.

As without the clock started, most cameras will not even make the camera visible to I2C
This unrelated change was in the branch of #165
And has now been pulled out of it.

This PR is only a change of a #if statement that adds the Portenta H7 to the line that enables the clock for the Giga.
And only if Video (Camera) is configured in the .conf files.

Currently the overlay for the PortentaH7 is setup with the configuration to run on the Mid Carrier board, which is
different than the Portenta Vision shield. At some point probably need to configure it for either. Not sure
what Arduino wishes to do for this. Define them as Shields in Zephyr and have multiple variants? But that
is beyond the scope of this simple change.

We need to start the clock in the same way as we do for the Arduino GIGA.

As without the clock started, most cameras will not even make the camera
visible to I2C
@KurtE KurtE force-pushed the enable_camera_on_h7 branch from a271049 to 3bbf8a0 Compare August 21, 2025 15:31
@KurtE
Copy link
Author

KurtE commented Aug 25, 2025

@iabdalkader @pillo79 @facchinm and others: As I have asked in issue #164 wondering best way to do this.

For example: currently it is setup like:

#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)) \
		&& defined(CONFIG_VIDEO)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/logging/log.h>

int camera_ext_clock_enable(void)
{
	int ret;
	uint32_t rate;
	const struct device *cam_ext_clk_dev = DEVICE_DT_GET(DT_NODELABEL(pwmclock));

	if (!device_is_ready(cam_ext_clk_dev)) {
		return -ENODEV;
	}

	ret = clock_control_on(cam_ext_clk_dev, (clock_control_subsys_t)0);
	if (ret < 0) {
		return ret;
	}

	ret = clock_control_get_rate(cam_ext_clk_dev, (clock_control_subsys_t)0, &rate);
	if (ret < 0) {
		return ret;
	}

	return 0;
}

SYS_INIT(camera_ext_clock_enable, POST_KERNEL, CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY);

#endif

Note: this includes my one line change in this PR to enable it on Portenta H7.

But I keep wondering on ArduinoCore-zephyr, that Not all user sketches use Cameras, and yet we always start up
a clock pin running doing PWM. Could this not all be done within the Camera::begin(...) method?
That way only done if the sketch actually does anything with Cameras. Wondering if starting up resources like this
when they may or may not be applicable is a good thing. For example if your board is running off of a battery,
will this cause unnecessary power drain?

Also with this, maybe define some way to allow the sketch to specify which pins and/or which Carrier/Shield they
are using. For example: on the Portenta H7, they don't all use the same pin for the Clock (PA_8, PK_1). They use the same
timer. I know that OpenMV starts the timer ands sets both pins MUX(AF) to the timer. But again not sure in this
case we want to dedicate two pins for this as again not all sketches uses cameras.
But maybe if there was something like: myCamera.setShield(PORTENTA_VISION_SHIELD); it could set the
time pin and probably the Reset (actually the power on pin) and PWDN (not applicable)...

Thoughts?

Edit: Note: there currently is no approved way to actually access the PK_1 pin on Zephyr. Except if it is called out
somewhere within the overlay files. That is there is no Arduino Pin number associated with it, nor do we have
access by pin names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant